<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品管理列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="manamge-form">
                <div class="select-list">
                    <ul>
                        <li>
                            产品名称：<input type="text" name="manageName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                <i class="fa fa-remove"></i> 删除
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:role:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:role:remove')}]];
    var prefix = ctx + "datum/manage";

    var perImg = ctx + "img/";


    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            detailUrl: prefix + "/detail/{id}",
            removeUrl: prefix + "/remove",
            modalName: "产品信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'manageId',
                    title: '产品型号',
                },
                {
                    field: 'manageName',
                    title: '产品名称',
                },
                {
                    field: 'manageImg',
                    title: '产品图片',
                    formatter: function(value, row, index) {
                        // 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
                        // 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
                        return $.table.imageView(perImg + row.manageImg);
                    }
                },
                {
                    field: 'seriesName',
                    title: '系列',
                },
                {
                    field: 'styleName',
                    title: '风格',
                },
                {
                    field: 'speName',
                    title: '规格',
                },
                {
                    field: 'manageTexture',
                    title: '材质',
                    /*  产品材质（1 面料2 五金件3 木饰面4 油漆5 其他）  */
                    formatter: function (value, row, index) {
                        if (row.manageTexture == 1) {
                            return "面料";
                        }else if(row.manageTexture == 2){
                            return "五金件";
                        }else if(row.manageTexture == 3){
                            return "木饰面";
                        }else if(row.manageTexture == 4){
                            return "油漆";
                        }else {
                            return "其他";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.manageId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.manageId + '\')"><i class="fa fa-check-square-o"></i>查看</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="photoView(\'' + row.priMesId + '\')"><i class="fa fa-check-square-o"></i>查看图库</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function photoView(priMesId) {
        var url = prefix + '/authPhoto/' + priMesId;
        $.modal.openTab("图片库查看", url);
    }
</script>
</body>
</html>